import http from '@/util/request.js'

export default {
    getUserById: (id) => {
        return http({
            url: `api/user/${id}`,
            method: 'get'
        })
    },
    
    getUserList: (data) => {
        return http({
            url: 'api/user/list',
            method: 'post',
            data
        })
    },
    
    addUser: (data) => {
        return http({
            url: 'api/user',
            method: 'post',
            data
        })
    },
    
    updateUser: (data) => {
        return http({
            url: 'api/user',
            method: 'put',
            data
        })
    },
    
    deleteUser: (id) => {
        return http({
            url: `api/user/${id}`,
            method: 'delete'
        })
    },
    
    getUserPage: (pageNum, pageSize, data) => {
        // 修改：使用正确的路径和参数传递方式
        return http({
            url: 'api/user/page',
            method: 'post',
            params: {
                pageNum: pageNum,
                pageSize: pageSize
            },
            data: data || {}
        })
    },
    // 获取司机申请列表
    getDriverApplications: () => {
        return http({
            url: 'api/user/driver-approval/applications',
            method: 'get'
        })
    },
    // 批准司机申请
    approveDriverApplication: (id) => {
        return http({
            url: `api/user/driver-approval/approve/${id}`,
            method: 'post'
        })
    },
    // 拒绝司机申请
    rejectDriverApplication: (id, reason) => {
        return http({
            url: `api/user/driver-approval/reject/${id}`,
            method: 'post',
            data: { reason: reason || '' }
        })
    }
}
